package domain.exceptions;

public class RestrictionBuyingException extends Exception{
	private static final long serialVersionUID = 1L;

	public static final int BLOCK_CODE=1;
	public static final int SAME_USER_CODE=2;
	public static final int STOCK_RESTRICTION_CODE=3;
	public static final int MINIMUM_STOCK_CODE=4;
	public static final int CANNOT_BUY_CODE=5;
	private int errorCode;
	
	public RestrictionBuyingException(int errorCode){
		super();
		this.errorCode=errorCode;
	}
	
	public RestrictionBuyingException(String msg){
		super(msg);
	}
	
	@Override
	public String getMessage(){
		switch(errorCode){
		case BLOCK_CODE:
			return "Either buyer or vendor is blocked";
		case SAME_USER_CODE:
			return "You cannot buy items from yourself";
		case STOCK_RESTRICTION_CODE:
			return "You cannot buy more items than the stock amount";
		case MINIMUM_STOCK_CODE:
			return "You have to buy at least one item";
		default:
			return "Restricted";	
		}
	}
}
